/**
 * lilang
 * WfcTaskAction.java
 * 2013-11-1上午10:32:41
 */
package com.cq.oa.web.wfc.action;

import java.util.List;

import oa.base.session.SessionManger;
import oa.base.util.Page;
import oa.base.web.Action.BaseAction;

import com.cq.oa.domain.wfc.Activity;
import com.cq.oa.domain.wfc.ActivityParticipation;
import com.cq.oa.domain.wfc.TaskInstance;
import com.cq.oa.service.util.ProcessUtils;
import com.cq.oa.service.work.WorkCenterService;

/**
 * @author lilang
 *
 */
public class WfcTaskAction extends BaseAction<TaskInstance>{

	/**
	 * lilang
	 * 2013-11-1上午10:37:12
	 */
	private static final long serialVersionUID = -5480193516532810264L;

	private Long activityId;
	
	
	public Long getActivityId() {
		return activityId;
	}


	public void setActivityId(Long activityId) {
		this.activityId = activityId;
	}


	/* (non-Javadoc)
	 * @see oa.base.web.Action.BaseAction#getEntityClass()
	 */
	@Override
	protected Class<TaskInstance> getEntityClass() {
		return TaskInstance.class;
	}
	
	private WorkCenterService workCenterService;

	public void setWorkCenterService(WorkCenterService workCenterService) {
		this.workCenterService = workCenterService;
	}

	
	public String findByPage() throws Exception{
		filterMap.put("reciveSid", SessionManger.getUserId());
		filterMap.put("taskStatus", ProcessUtils.TASK_START);
		Page<TaskInstance> page = this.workCenterService.findTaskByOwn(filterMap, getPageNo(), getPageSize());
		this.renderJsonSuccess(jsonUtils.getExtJson(page, new String[] {}));
		return JSON;
	}
	
	/**
	 * 查询下一步处理人
	 * @return
	 * @throws Exception
	 * lilang 
	 * 2013-11-1下午12:31:47
	 */
	public String findNextNode() throws Exception{
		List<Activity>  activities=this.workCenterService.getNextActivity(entity.getSid());
		this.renderJsonSuccess(jsonUtils.getExtArrayJson(activities));
		return JSON;
	}
	/**
	 * 获取处理数据
	 * @return
	 * lilang 
	 * 2013-11-1下午1:20:39
	 */
	public String findActivityPartion(){
		List<ActivityParticipation> activityParticipations=this.workCenterService.getActivityParticipation(activityId);
		if(!activityParticipations.isEmpty()){
			ActivityParticipation participation = activityParticipations.get(0);
			//全单位
			if(participation.getType()==ProcessUtils.ALL_COMPANY){
				
			//部门
			}else if(participation.getType()==ProcessUtils.DEPT_TYPE){
				
			//岗位
			}else if(participation.getType()==ProcessUtils.POST_TYPE){
				
			//人员
			}else if(participation.getType()==ProcessUtils.PERSON_TYPE){
				
			//活动
			}else if(participation.getType()==ProcessUtils.ACTIVITY_TYPE){
				
			}else{
				
			}
		}
		return JSON;
	}
	
	
	
	public String taskOper(){
		return	"taskOper";
	}
}
